<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
abstract class BaseClass{
    
    public $keyword;
    public $fields;
    public $data;
    public $insertData=array();

    function __construct($data, $EE) {
        $this->data=$data;
        $this->keyword=explode("\n", $data['keyword']);
        $this->EE=$EE;
    }
    
    /*
     * get data from db
     */
    function apiOptions($api){
        $query=$this->EE->db->get_where('spider_'.$api, array('campaign_id'=>  $this->data['campaign_id']));
        if($query->num_rows==0){
            return FALSE;
        }
        return $query->row_array();
    }
    
    function getFields($api){
        $this->EE->db->select('fields');
        $query=$this->EE->db->get_where('spider_fields', array('campaign_id'=>$this->data['campaign_id'], 'api_name'=>$api));
        
        if($query->num_rows==0){
            return false;
        }
        $fields=$query->row_array();
        
        return unserialize($fields['fields']);;
    }

    abstract function getData();
}
